
task :default do
  Rake.application.options.show_task_pattern = /./
  Rake.application.display_tasks_and_comments
end

#####

require 'rubygems'
gem 'ludy', '>=0.1.7'
require 'ludy/tasks/preprocess_cpp'
Project.name = 'shooting_cubes'

#####

require 'rake/clean'
require 'fileutils'
CLEAN.include '*.o'
task :clobber => :clean do
  sh 'make clean' rescue nil
  File.delete 'Makefile' rescue nil
  File.delete 'CMakeCache.txt' rescue nil
  File.delete 'cmake_install.cmake' rescue nil
  FileUtils.rm_r 'CMakeFiles' rescue nil
end

#####

file :Makefile do
  sh 'cmake .'
end

desc 'preprocess and build'
task :build => [:prepare, :Makefile] do
  sh 'make'
end

desc 'clobber and build'
task :rebuild => [:clobber, :build]

desc 'prepare for build, doing custom preprocessing'
task :prepare => [:preprocess,
                  :reprocess_CMakeLists]

##

task :reprocess_CMakeLists do
  File.delete 'CMakeLists.txt'
  sh 'rake CMakeLists.txt'
end

##

namespace :svk do
  %w{commit push pull status update}.each{ |cmd|
    desc "svk #{cmd}"
    task(cmd){sh "svk #{cmd}"}
  }
end
